<?php
/**
 *
 * @author Strawberry🍓
 * @date 2021-05-24 4:51 下午
 *
 */

namespace app\common\model\tang;


use app\common\impl\Comm;
use app\common\model\CommonBaseModel;

class RepairMarrer extends CommonBaseModel implements Comm
{
    protected $autoWriteTimestamp = 'int';//指定数字格式
    protected $createTime = 'create_time';//创建时间

    public function getAdminPageData($param = [], $order = 'id desc')
    {
        // TODO: Implement getAdminPageData() method.
        $where = [];
        $model = self::where($where);
        $model->where('merchant_id', '<>', 0);
        if (isset($param['merchant_id']) && $param['merchant_id']) {
            $model->where('merchant_id', '=', $param['merchant_id']);
        }
        $data = $model->with(['merchant','repair'])->order($order)->page(PAGE)->limit(LIMIT)->select()->toArray();
        $count = $model->count("id");
        return parent::ajaxResult($data, $count);
    }

    public function delById($id)
    {
        // TODO: Implement delById() method.
    }

    public function doAll($data)
    {
        // TODO: Implement doAll() method.
        return parent::doAllData($data);
    }

    public function merchant(): \think\model\relation\HasOne
    {
        return $this->hasOne(Merchant::class, 'id', 'merchant_id');
    }
    public function repair(): \think\model\relation\HasOne
    {
        return $this->hasOne(RepairMarrerConfig::class, 'id', 'type')->bind([
            'title'=>'title'
        ]);
    }
}